package org.orbroker.callback

/**
 * Notification callback when executing SQL.
 * @author Nils Kilden-Pedersen
 */
trait ExecutionCallback {
  /**
   * Single SQL statement executed.
   * @param id The SQL statement ID
   * @param sql SQL statement executed
   * @param parms Parameters, if any
   * @param executionTime SQL execution time in microseconds
   */
  def onSQL(id: Symbol, sql: String, parms: Seq[Any], executionTime: Int)
  
  /**
   * Batch SQL statement executed.
   * @param id The SQL statement ID
   * @param sql SQL statement executed
   * @param parms Parameters per batch, if any
   * @param executionTime SQL execution time in microseconds
   */
  def onSQLBatch(id: Symbol, sql: String, parms: Seq[Seq[Any]], executionTime: Int)
  
  /**
   * SQL execution warning. This will be called for every warning in
   * a chain.
   * @param warning A SQL warning
   */
  def onWarning(warning: java.sql.SQLWarning)
}

private[orbroker] object Deaf extends ExecutionCallback {
  def onSQL(id: Symbol, sql: String, parms: Seq[Any], executionTime: Int) {}
  def onSQLBatch(id: Symbol, sql: String, parms: Seq[Seq[Any]], executionTime: Int) {}
  def onWarning(warning: java.sql.SQLWarning) {}
}
